home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 February / Gamestar_81_2006-02_dvd.iso / Red Shark / Missions / Mission_2 / Mission.script < prev    next >
Text File  |  2001-12-24  |  16KB  |  371 lines

  1. //-------------------------------------------------------------------
  2. //
  3. //  This code is copyright 2001 by G5 Software.
  4. //  Any unauthorized usage, either in part or in whole of this code
  5. //  is strictly prohibited. Violators WILL be prosecuted to the
  6. //  maximum extent allowed by law.
  7. //
  8. //-------------------------------------------------------------------
  9.  
  10. class CConvoyMission extends
  11.   CBaseMission, CConvoyMissionObjectList, CConvoyMission_Strings, CNavPointUser
  12. {
  13.   //
  14.   //  settings
  15.   //
  16.  
  17.   int GetAutoGeneratedUnitsQty()
  18.   {
  19.     return 6;
  20.   }
  21.  
  22.   void CConvoyMission()
  23.   {
  24.     BaseMission_InitMission();
  25.  
  26.     BaseMission_UpdateLoadProgress();
  27.     CreateComponent("DebugCamera", "GameObject", "CDebugCamera");
  28.     SetComponentPosition("DebugCamera",
  29.       matrix(
  30.         1.0, 0.0, 0.0, 5000.0,
  31.         0.0, 1.0, 0.0,  400.0,
  32.         0.0, 0.0, 1.0,  600.0,
  33.         0.0, 0.0, 0.0,    1.0
  34.       ));
  35.  
  36.     // CreateComponent(IDToRegister, ComponentID, ScriptName | FileName | "")
  37.     BaseMission_UpdateLoadProgress();
  38.     CreateComponent("Atmosphere", "Atmosphere", "CConvoyMission_Atmosphere");
  39.  
  40.     BaseMission_UpdateLoadProgress();
  41.     CreateComponent("Sky", "SkyObject", "CConvoyMission_Sky");
  42.  
  43.     BaseMission_UpdateLoadProgress();
  44.     CreateComponent("Terrain", "ProgressiveTerrainObject", "CConvoyMission_Terrain");
  45.  
  46.     BaseMission_UpdateLoadProgress();
  47.     CreateComponent("Forest", "Forest", "CConvoyMission_Forest");
  48.  
  49.     BaseMission_UpdateLoadProgress();
  50.     CreateComponent("AIController", "AIController", "CConvoyMission_AIController");
  51.  
  52.     BaseMission_CreateObjects();
  53.  
  54.  
  55.     // create AI controller
  56.  
  57.  
  58.     // give tasks to AI game objects
  59.  
  60.     // convoy guards
  61.     SetBehaviorTask( "SovietTank_Guard 1", "CConvoyMission_SovietTank_ConvoyGuard");
  62.     SetBehaviorTask( "SovietTank_Guard 2", "CConvoyMission_SovietTank_ConvoyGuard");
  63.     SetBehaviorTask( "SovietTank_Guard 3", "CConvoyMission_SovietTank_ConvoyGuard");
  64.     SetBehaviorTask( "SovietTank_Guard 4", "CConvoyMission_SovietTank_ConvoyGuard");
  65.  
  66.     // convoy transports
  67.     SetBehaviorTask( "SovietTruck_Transport 1", "CConvoyMission_SovietTruck_ConvoyTransport");
  68.     SetBehaviorTask( "SovietTruck_Transport 2", "CConvoyMission_SovietTruck_ConvoyTransport");
  69.     SetBehaviorTask( "SovietTruck_Transport 3", "CConvoyMission_SovietTruck_ConvoyTransport");
  70.     SetBehaviorTask( "SovietTruck_Transport 4", "CConvoyMission_SovietTruck_ConvoyTransport");
  71.     SetBehaviorTask( "SovietTruck_Transport 5", "CConvoyMission_SovietTruck_ConvoyTransport");
  72.     SetBehaviorTask( "SovietTruck_Transport 6", "CConvoyMission_SovietTruck_ConvoyTransport");
  73.     SetBehaviorTask( "SovietTruck_Transport 7", "CConvoyMission_SovietTruck_ConvoyTransport");
  74.     SetBehaviorTask( "SovietTruck_Transport 8", "CConvoyMission_SovietTruck_ConvoyTransport");
  75.     SetBehaviorTask( "SovietTruck_Transport 9", "CConvoyMission_SovietTruck_ConvoyTransport");
  76.     SetBehaviorTask( "SovietTruck_Transport 10", "CConvoyMission_SovietTruck_ConvoyTransport");
  77.     SetBehaviorTask( "SovietTruck_Transport 11", "CConvoyMission_SovietTruck_ConvoyTransport");
  78.     SetBehaviorTask( "SovietTruck_Transport 12", "CConvoyMission_SovietTruck_ConvoyTransport");
  79.  
  80.     // Ambush 1
  81.     SetBehaviorTask( "NaziTank_Ambusher_1 1", "CConvoyMission_NaziTank_BackAttacker_1");
  82.     SetBehaviorTask( "NaziTank_Ambusher_1 2", "CConvoyMission_NaziTank_BackAttacker_1");
  83.  
  84.     // Ambush 2
  85.     SetBehaviorTask( "NaziTank_Ambusher_2 1", "CConvoyMission_NaziTank_BackAttacker_2");
  86.     SetBehaviorTask( "NaziTank_Ambusher_2 2", "CConvoyMission_NaziTank_BackAttacker_2");
  87.  
  88.  
  89.     // all other ambushes
  90.     SetBehaviorTask( "NaziTank_Ambush_1 1", "CConvoyMission_NaziTank_TransportKiller");
  91.     SetBehaviorTask( "NaziTank_Ambush_2 1", "CConvoyMission_NaziTank_TransportKiller");
  92.     SetBehaviorTask( "NaziTank_Ambush_3 1", "CConvoyMission_NaziTank_TransportKiller");
  93.     SetBehaviorTask( "NaziTank_Ambush_4 1", "CConvoyMission_NaziTank_TransportKiller");
  94.     SetBehaviorTask( "NaziTank_Ambush_5 1", "CConvoyMission_NaziTank_TransportKiller");
  95.     SetBehaviorTask( "NaziTank_Ambush_1 2", "CConvoyMission_NaziTank_TransportKiller");
  96.     SetBehaviorTask( "NaziTank_Ambush_2 2", "CConvoyMission_NaziTank_TransportKiller");
  97.     SetBehaviorTask( "NaziTank_Ambush_2 3", "CConvoyMission_NaziTank_TransportKiller");
  98.     SetBehaviorTask( "NaziTank_Ambush_2 4", "CConvoyMission_NaziTank_TransportKiller");
  99.     SetBehaviorTask( "NaziTank_Ambush_3 2", "CConvoyMission_NaziTank_TransportKiller");
  100.     SetBehaviorTask( "NaziTank_Ambush_3 3", "CConvoyMission_NaziTank_TransportKiller");
  101.     SetBehaviorTask( "NaziTank_Ambush_3 4", "CConvoyMission_NaziTank_TransportKiller");
  102.     SetBehaviorTask( "NaziTank_Ambush_4 2", "CConvoyMission_NaziTank_TransportKiller");
  103.     SetBehaviorTask( "NaziTank_Ambush_4 3", "CConvoyMission_NaziTank_TransportKiller");
  104.     SetBehaviorTask( "NaziTank_Ambush_4 4", "CConvoyMission_NaziTank_TransportKiller");
  105.     SetBehaviorTask( "NaziTank_Ambush_5 2", "CConvoyMission_NaziTank_TransportKiller");
  106.     SetBehaviorTask( "NaziTank_Ambush_5 3", "CConvoyMission_NaziTank_TransportKiller");
  107.     SetBehaviorTask( "NaziTank_Ambush_5 4", "CConvoyMission_NaziTank_TransportKiller");
  108.     SetBehaviorTask( "NaziTank_Ambush_5 5", "CConvoyMission_NaziTank_TransportKiller");
  109.     SetBehaviorTask( "NaziTank_Ambush_5 6", "CConvoyMission_NaziTank_TransportKiller");
  110.     SetBehaviorTask( "NaziTank_Ambush_5 7", "CConvoyMission_NaziTank_TransportKiller");
  111.     SetBehaviorTask( "NaziTank_Ambush_5 8", "CConvoyMission_NaziTank_TransportKiller");
  112.     SetBehaviorTask( "NaziTank_Ambush_6 1", "CConvoyMission_NaziTank_TransportKiller");
  113.     SetBehaviorTask( "NaziTank_Ambush_6 2", "CConvoyMission_NaziTank_TransportKiller");
  114.     SetBehaviorTask( "NaziTank_Ambush_6 3", "CConvoyMission_NaziTank_TransportKiller");
  115.     SetBehaviorTask( "NaziTank_Ambush_6 4", "CConvoyMission_NaziTank_TransportKiller");
  116.     SetBehaviorTask( "NaziTank_Ambush_6 5", "CConvoyMission_NaziTank_TransportKiller");
  117.     SetBehaviorTask( "NaziTank_Ambush_6 6", "CConvoyMission_NaziTank_TransportKiller");
  118.     SetBehaviorTask( "NaziTank_Ambush_6 7", "CConvoyMission_NaziTank_TransportKiller");
  119.     SetBehaviorTask( "NaziTank_Ambush_6 8", "CConvoyMission_NaziTank_TransportKiller");
  120.     SetBehaviorTask( "NaziTank_Ambush_6 9", "CConvoyMission_NaziTank_TransportKiller");
  121.     SetBehaviorTask( "NaziTank_Ambush_6 10", "CConvoyMission_NaziTank_TransportKiller");
  122.     SetBehaviorTask( "NaziTank_Ambush_6 11", "CConvoyMission_NaziTank_TransportKiller");
  123.     SetBehaviorTask( "NaziTank_Ambush_6 12", "CConvoyMission_NaziTank_TransportKiller");
  124.     SetBehaviorTask( "NaziTank_Ambush_6 13", "CConvoyMission_NaziTank_TransportKiller");
  125.     SetBehaviorTask( "NaziTank_Ambush_6 14", "CConvoyMission_NaziTank_TransportKiller");
  126.     SetBehaviorTask( "NaziTank_Ambush_6 15", "CConvoyMission_NaziTank_TransportKiller");
  127.     SetBehaviorTask( "NaziTank_Ambush_6 16", "CConvoyMission_NaziTank_TransportKiller");
  128.     SetBehaviorTask( "NaziTank_Ambush_6 17", "CConvoyMission_NaziTank_TransportKiller");
  129.     SetBehaviorTask( "NaziTank_Ambush_6 18", "CConvoyMission_NaziTank_TransportKiller");
  130.  
  131.  
  132.     // guardians direction
  133.     SetBehaviorGroupRank( "SovietTank_Guard 1", "Guard_Rank", 1);
  134.     SetBehaviorGroupRank( "SovietTank_Guard 2", "Guard_Rank", 2);
  135.     SetBehaviorGroupRank( "SovietTank_Guard 3", "Guard_Rank", 3);
  136.     SetBehaviorGroupRank( "SovietTank_Guard 4", "Guard_Rank", 4);
  137.  
  138.     // column direction
  139.     SetBehaviorGroupRank( "SovietTank_Guard 1", "Convoy_Rank", 1);
  140.     SetBehaviorGroupRank( "SovietTank_Guard 2", "Convoy_Rank", 2);
  141.     SetBehaviorGroupRank( "SovietTank_Guard 3", "Convoy_Rank", 3);
  142.     SetBehaviorGroupRank( "SovietTank_Guard 4", "Convoy_Rank", 4);
  143.     SetBehaviorGroupRank( "SovietTruck_Transport 1", "Convoy_Rank", 5);
  144.     SetBehaviorGroupRank( "SovietTruck_Transport 2", "Convoy_Rank", 6);
  145.     SetBehaviorGroupRank( "SovietTruck_Transport 3", "Convoy_Rank", 7);
  146.     SetBehaviorGroupRank( "SovietTruck_Transport 4", "Convoy_Rank", 8);
  147.     SetBehaviorGroupRank( "SovietTruck_Transport 5", "Convoy_Rank", 9);
  148.     SetBehaviorGroupRank( "SovietTruck_Transport 6", "Convoy_Rank", 10);
  149.     SetBehaviorGroupRank( "SovietTruck_Transport 7", "Convoy_Rank", 11);
  150.     SetBehaviorGroupRank( "SovietTruck_Transport 8", "Convoy_Rank", 12);
  151.     SetBehaviorGroupRank( "SovietTruck_Transport 9", "Convoy_Rank", 13);
  152.     SetBehaviorGroupRank( "SovietTruck_Transport 10", "Convoy_Rank", 14);
  153.     SetBehaviorGroupRank( "SovietTruck_Transport 11", "Convoy_Rank", 15);
  154.     SetBehaviorGroupRank( "SovietTruck_Transport 12", "Convoy_Rank", 16);
  155.  
  156.     // ambush direction
  157.     SetBehaviorGroupRank( "NaziTank_Ambush_1 1", "RangedAmbushRank", 1);
  158.     SetBehaviorGroupRank( "NaziTank_Ambush_2 1", "RangedAmbushRank", 2);
  159.     SetBehaviorGroupRank( "NaziTank_Ambush_3 1", "RangedAmbushRank", 3);
  160.     SetBehaviorGroupRank( "NaziTank_Ambush_4 1", "RangedAmbushRank", 4);
  161.     SetBehaviorGroupRank( "NaziTank_Ambush_5 1", "RangedAmbushRank", 5);
  162.     SetBehaviorGroupRank( "NaziTank_Ambush_1 2", "RangedAmbushRank", 6);
  163.     SetBehaviorGroupRank( "NaziTank_Ambush_2 2", "RangedAmbushRank", 7);
  164.     SetBehaviorGroupRank( "NaziTank_Ambush_2 3", "RangedAmbushRank", 8);
  165.     SetBehaviorGroupRank( "NaziTank_Ambush_2 4", "RangedAmbushRank", 9);
  166.     SetBehaviorGroupRank( "NaziTank_Ambush_3 2", "RangedAmbushRank", 10);
  167.     SetBehaviorGroupRank( "NaziTank_Ambush_3 3", "RangedAmbushRank", 11);
  168.     SetBehaviorGroupRank( "NaziTank_Ambush_3 4", "RangedAmbushRank", 12);
  169.     SetBehaviorGroupRank( "NaziTank_Ambush_4 2", "RangedAmbushRank", 13);
  170.     SetBehaviorGroupRank( "NaziTank_Ambush_4 3", "RangedAmbushRank", 14);
  171.     SetBehaviorGroupRank( "NaziTank_Ambush_4 4", "RangedAmbushRank", 15);
  172.     SetBehaviorGroupRank( "NaziTank_Ambush_5 2", "RangedAmbushRank", 16);
  173.     SetBehaviorGroupRank( "NaziTank_Ambush_5 3", "RangedAmbushRank", 17);
  174.     SetBehaviorGroupRank( "NaziTank_Ambush_5 4", "RangedAmbushRank", 18);
  175.     SetBehaviorGroupRank( "NaziTank_Ambush_5 5", "RangedAmbushRank", 19);
  176.     SetBehaviorGroupRank( "NaziTank_Ambush_5 6", "RangedAmbushRank", 20);
  177.     SetBehaviorGroupRank( "NaziTank_Ambush_5 7", "RangedAmbushRank", 21);
  178.     SetBehaviorGroupRank( "NaziTank_Ambush_5 8", "RangedAmbushRank", 22);
  179.     SetBehaviorGroupRank( "NaziTank_Ambush_6 1", "RangedAmbushRank", 23);
  180.     SetBehaviorGroupRank( "NaziTank_Ambush_6 2", "RangedAmbushRank", 24);
  181.     SetBehaviorGroupRank( "NaziTank_Ambush_6 3", "RangedAmbushRank", 25);
  182.     SetBehaviorGroupRank( "NaziTank_Ambush_6 4", "RangedAmbushRank", 26);
  183.     SetBehaviorGroupRank( "NaziTank_Ambush_6 5", "RangedAmbushRank", 27);
  184.     SetBehaviorGroupRank( "NaziTank_Ambush_6 6", "RangedAmbushRank", 28);
  185.     SetBehaviorGroupRank( "NaziTank_Ambush_6 7", "RangedAmbushRank", 29);
  186.     SetBehaviorGroupRank( "NaziTank_Ambush_6 8", "RangedAmbushRank", 30);
  187.     SetBehaviorGroupRank( "NaziTank_Ambush_6 9", "RangedAmbushRank", 31);
  188.     SetBehaviorGroupRank( "NaziTank_Ambush_6 10", "RangedAmbushRank", 32);
  189.     SetBehaviorGroupRank( "NaziTank_Ambush_6 11", "RangedAmbushRank", 33);
  190.     SetBehaviorGroupRank( "NaziTank_Ambush_6 12", "RangedAmbushRank", 34);
  191.     SetBehaviorGroupRank( "NaziTank_Ambush_6 13", "RangedAmbushRank", 35);
  192.     SetBehaviorGroupRank( "NaziTank_Ambush_6 14", "RangedAmbushRank", 36);
  193.     SetBehaviorGroupRank( "NaziTank_Ambush_6 15", "RangedAmbushRank", 37);
  194.     SetBehaviorGroupRank( "NaziTank_Ambush_6 16", "RangedAmbushRank", 38);
  195.     SetBehaviorGroupRank( "NaziTank_Ambush_6 17", "RangedAmbushRank", 39);
  196.     SetBehaviorGroupRank( "NaziTank_Ambush_6 18", "RangedAmbushRank", 40);
  197.  
  198.     //
  199.     //  Mission specific
  200.     //
  201.  
  202.     // count how many 1st and 2nd objectives' objects are in the mission
  203.     array m_Objects = GetObjectsIDs();
  204.  
  205.     m_ConvoyCount  = 0;
  206.     m_EnemiesCount = 0;
  207.  
  208.     for (int i = 0; i < m_Objects.size(); i = i + 1)
  209.     {
  210.       if (Core_IsStringStartsWith(m_Objects[i], "SovietTruck_Transport"))
  211.         m_ConvoyCount = m_ConvoyCount + 1;
  212.  
  213.       if (Core_IsStringStartsWith(m_Objects[i], "Nazi"))
  214.         m_EnemiesCount = m_EnemiesCount + 1;
  215.     }
  216.  
  217.     m_ConvoyDestroyed = 0;
  218.   }
  219.  
  220.   int  m_ConvoyCount;
  221.   int  m_ConvoyDestroyed;
  222.   int  m_EnemiesCount;
  223.  
  224.   array m_MissionObjectivesStatuses =
  225.           array(
  226.             str_ObjectiveInProgress
  227.           );
  228.  
  229.   array m_BonusMissionObjectivesStatuses =
  230.           array(
  231.           );
  232.  
  233.   //
  234.   //  'virtual' methods
  235.   //
  236.  
  237.   //
  238.   //  Objectives
  239.  
  240.   array GetMissionObjectives()
  241.   {
  242.     return m_MissionObjectives;
  243.   }
  244.  
  245.   array GetMissionObjectivesStatuses()
  246.   {
  247.     return m_MissionObjectivesStatuses;
  248.   }
  249.  
  250.   void SetMissionObjectiveStatus(int _obj, string _status)
  251.   {
  252.     m_MissionObjectivesStatuses[_obj] = _status;
  253.   }
  254.  
  255.   //
  256.   //  Bonus objectives
  257.  
  258.   array GetBonusMissionObjectives()
  259.   {
  260.     return m_BonusMissionObjectives;
  261.   }
  262.  
  263.   array GetBonusMissionObjectivesStatuses()
  264.   {
  265.     return m_BonusMissionObjectivesStatuses;
  266.   }
  267.  
  268.   void SetBonusMissionObjectiveStatus(int _obj, string _status)
  269.   {
  270.     m_BonusMissionObjectivesStatuses[_obj] = _status;
  271.   }
  272.  
  273.   //
  274.   //  Mission statistics
  275.  
  276.   string GetMissionStatistics()
  277.   {
  278.     int percent = m_ConvoyDestroyed * 100.0 / m_ConvoyCount;
  279.     return str_StatisticsTitle_1 + percent + str_StatisticsTitle_2;
  280.   }
  281.  
  282.   //
  283.   //  Mission navpoints
  284.  
  285.   array GetNavPoints()
  286.   {
  287.     array navpoints =
  288.       array(
  289.           GetNavPoint("NavPoint_Ermoshino"),
  290.           GetNavPoint("NavPoint_Vasilievka"),
  291.           GetNavPoint("NavPoint_Laptevka"),
  292.           GetNavPoint("NavPoint_K140"),
  293.           GetNavPoint("NavPoint_A35")
  294. //        vector(12431.0, 3664.0, 1000.0),
  295. //        vector(10351.0, 7905.0, 1000.0),
  296. //        vector(4593.0, 10088.0, 1000.0),
  297. //        vector(3398.0, 14658.0, 1000.0),
  298. //        vector(6206.0, 1106.0, 1000.0)
  299.       );
  300.     return navpoints;
  301.   }
  302.  
  303.   //
  304.   //  Mission map skin file
  305.  
  306.   string GetMapSkinFileName()
  307.   {
  308.     return "Missions/Mission_2/Map.skin";
  309.   }
  310.  
  311.   //
  312.   //  Mission specific event handlers
  313.   //
  314.  
  315.   //
  316.   //  Object destroyed event handler
  317.   //
  318.  
  319.   void OnGameObjectDestroyed(string _id)
  320.   {
  321.     BaseMission_OnGameObjectDestroyed(_id);
  322.  
  323.     if (Core_IsStringStartsWith(_id, "Nazi"))
  324.     {
  325.       m_EnemiesCount = m_EnemiesCount - 1;
  326.     }
  327.  
  328.     if (Core_IsStringStartsWith(_id, "SovietTruck_Transport"))
  329.     {
  330.       m_ConvoyDestroyed = m_ConvoyDestroyed + 1;
  331.       int percent = 100.0 - m_ConvoyDestroyed * 100.0 / m_ConvoyCount;
  332.  
  333.       string message = str_WarningMessage_1 + percent + str_WarningMessage_2;
  334.  
  335.       Core_BroadcastEvent(
  336.         "OnDisplayMessage",
  337.         message,
  338.         m_BadNewsColor
  339.       );
  340.      Core_SendEventTo(
  341.         "Helicopter",
  342.         "ShowEventObject",
  343.         _id,                       //     - id of object to show
  344.         100.0                         //     - distance from camera to object
  345.         );
  346.     }
  347.  
  348.     // #UGLY bonus objective removed by vlud - it didn't work and was boring
  349.     // check for bonus objective completion
  350.     //if (m_EnemiesCount == 0)
  351.       //BaseMission_CompleteBonusObjective(0);
  352.  
  353.     // check for 50% of the convoy destroyed
  354.     if (m_ConvoyDestroyed > m_ConvoyCount/2)
  355.       BaseMission_DelayedQuit();
  356.   }
  357.  
  358.   void OnTransportsEnteredDestinationZone()
  359.   {
  360.     BaseMission_CompleteObjective(0);
  361.   }
  362.  
  363.   void OnMissionLoaded()
  364.   {
  365.     Core_SendEventTo("Helicopter", "OnInitiallyEnableTargetScreen", false);
  366.  
  367.     // Start mission music playing
  368.     Core_SendEventTo(SOID_MusicController, "PlayMissionMusic", 2);
  369.   }
  370. }
  371.